package com.demo.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.demo.action.GridAction;
import com.demo.action.TreeAction;

@SuppressWarnings("unchecked")
public class BaseAction extends HttpServlet{

	private static final long serialVersionUID = 1L;
	
	public BaseAction(){
		super();
	}
	public void destroy(){
		super.destroy();
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		response.setContentType("text/html;charset=utf-8");
		
		GridAction ga = new GridAction();
		TreeAction ta = new TreeAction();
		
		String method = request.getParameter("method");
		if(method != null){
			if(method.equals("getGridData")){
				ga.getGridData(request, response);
			}else if(method.equals("getTreeData")){
				ta.getTreeData(request, response);
			}else{
				//404
			}
		}else{
			//404
		}
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		doGet(request, response);
	}
	public void init() throws ServletException{}
}